package cn.smbms.controller;

import cn.smbms.beans.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @Version 1.0
 * @Author:陈慧杰
 * @Date:2021/11/30
 */
@Controller
public class IndexController extends AbstractController {
    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        System.out.println("控制后台打印的内容");
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("shouye");
        return modelAndView;
    }
    @RequestMapping("welcome")
    public  ModelAndView welcome(@RequestParam String userName){
        System.out.println(userName);
       return  new ModelAndView();

    }
    @RequestMapping(value = "welcome1",method = RequestMethod.GET,params = "userName")
     public ModelAndView welcome1(String userName){
          System.out.println(userName);
        ModelAndView modelAndView = new ModelAndView();
        User user = new User();
        user.setUserName("userName");
        modelAndView.addObject("tempUser",user);
        modelAndView.setViewName("welcome");
         return modelAndView;
    }
    @RequestMapping("welcome2")
    public String welcome2(String userName , Map<String ,Object> map){
        map.put("name",userName);
        return "welcome";


    }
}
